use std::time::Duration;
use thiserror;

#[derive(Debug, thiserror::Error)]
pub enum ATAdapterSendError {
    #[error("SendError")]
    SendError,
}

#[derive(Debug, thiserror::Error)]
pub enum ATAdapterRecvError {
    #[error("RecvEmpty")]
    RecvEmpty,
    #[error("RecvError")]
    RecvError,
    #[error("RecvTimeoutError")]
    RecvTimeoutError,
    #[error("RecvDisconnected")]
    RecvDisconnected,
}

pub trait ATAdapter {
    fn send(&mut self, m: &str) -> Result<usize, ATAdapterSendError>;
    // fn recv(&mut self) -> Result<String, ATAdapterRecvError>;
    fn recv_timeout(&mut self, timeout: Duration) -> Result<String, ATAdapterRecvError>;
    fn try_recv(&mut self) -> Result<String, ATAdapterRecvError>;
}
